/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "notas_remi", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "NotasRemi.findAll", query = "SELECT n FROM NotasRemi n"),
    @NamedQuery(name = "NotasRemi.findByReCod", query = "SELECT n FROM NotasRemi n WHERE n.reCod = :reCod"),
    @NamedQuery(name = "NotasRemi.findByTipo", query = "SELECT n FROM NotasRemi n WHERE n.tipo = :tipo"),
    @NamedQuery(name = "NotasRemi.findByFecha", query = "SELECT n FROM NotasRemi n WHERE n.fecha = :fecha"),
    @NamedQuery(name = "NotasRemi.findByEstado", query = "SELECT n FROM NotasRemi n WHERE n.estado = :estado")})
public class NotasRemi implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "re_cod", nullable = false)
    private Integer reCod;
    @Size(max = 30)
    @Column(name = "tipo", length = 30)
    private String tipo;
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Size(max = 2)
    @Column(name = "estado", length = 2)
    private String estado;
    @ManyToMany(mappedBy = "notasRemiCollection")
    private Collection<Facturas> facturasCollection;
    @JoinTable(name = "nota_consigna", joinColumns = {
        @JoinColumn(name = "re_cod", referencedColumnName = "re_cod", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "cli_cod", referencedColumnName = "cli_cod", nullable = false)})
    @ManyToMany
    private Collection<Clientes> clientesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "notasRemi")
    private Collection<NotaRemiDet> notaRemiDetCollection;

    public NotasRemi() {
    }

    public NotasRemi(Integer reCod) {
        this.reCod = reCod;
    }

    public Integer getReCod() {
        return reCod;
    }

    public void setReCod(Integer reCod) {
        this.reCod = reCod;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getEstado() {
        return estado;
    }

    public void setEstado(String estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<Facturas> getFacturasCollection() {
        return facturasCollection;
    }

    public void setFacturasCollection(Collection<Facturas> facturasCollection) {
        this.facturasCollection = facturasCollection;
    }

    @XmlTransient
    public Collection<Clientes> getClientesCollection() {
        return clientesCollection;
    }

    public void setClientesCollection(Collection<Clientes> clientesCollection) {
        this.clientesCollection = clientesCollection;
    }

    @XmlTransient
    public Collection<NotaRemiDet> getNotaRemiDetCollection() {
        return notaRemiDetCollection;
    }

    public void setNotaRemiDetCollection(Collection<NotaRemiDet> notaRemiDetCollection) {
        this.notaRemiDetCollection = notaRemiDetCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reCod != null ? reCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NotasRemi)) {
            return false;
        }
        NotasRemi other = (NotasRemi) object;
        if ((this.reCod == null && other.reCod != null) || (this.reCod != null && !this.reCod.equals(other.reCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.NotasRemi[ reCod=" + reCod + " ]";
    }
    
}
